<?php


abstract class Account {
    protected $principal=1000;//本金
    protected $interest;//利息
    public function getPrincipal(){
        return $this->principal;
    }
    public function getInterest(){
        //利息=利率*本金
        $this->interest=$this->principal*$this->getInterestRate();
        return $this->interest;
    }
    abstract function getInterestRate();
}

class ABC extends Account{
    //必须全部实现抽像方法
    function getInterestRate(){
        echo '我是农业银行的计算方式<br/>';
        return 0.5;
    }
}
class ICBC extends Account{
    //必须全部实现抽像方法
    function getInterestRate(){
        echo '我是工商银行的计算方式<br/>';
        return 0.6;
    }
}

$lisi = new ABC();
echo $lisi->getInterest();
echo'<br/>';

$zhangsan = new ICBC();
echo $zhangsan->getInterest();
